package cn.nami.web.frontpage.entity;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import cn.nami.web.db.util.IConstant;
import cn.nami.web.util.DateUtil;

/**
 * the description about the visitor.
 * @author nami
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Visitor
{
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private String visitDate;

	@Persistent
	private String ip;
	
	@Persistent
	private String address;
	
	public Visitor(){};
	
	public Visitor(String ip, String address, String visitDate)
	{
		this.ip = ip;
		this.address = address;
		this.visitDate = visitDate;
	}
	public Visitor(String ip, String address, Date visitDate)
	{
		this.ip = ip;
		this.address = address;
		this.visitDate = DateUtil.formatDate(visitDate);
	}

	public Long getId()
	{
		return id;
	}
	public void setId(Long id)
	{
		this.id = id;
	}
	public String getVisitDate()
	{
		return visitDate;
	}
	public void setVisitDate(String visitDate)
	{
		this.visitDate = visitDate;
	}
	public void setVisitDate(Date visitDate)
	{
		this.visitDate = DateUtil.formatDate(visitDate);
	}
	public String getIp()
	{
		return ip;
	}
	public void setIp(String ip)
	{
		this.ip = ip;
	}
	
	public String getAddress()
	{
		return address;
	}

	public void setAddress(String address)
	{
		this.address = address;
	}

	public String toString()
	{
		StringBuffer buf = new StringBuffer(100);
		buf.append("\tid : ").append(id).append(IConstant.SYS_NEXT_LINE)
			.append("\tip : ").append(ip).append(IConstant.SYS_NEXT_LINE)
			.append("\taddress : ").append(address).append(IConstant.SYS_NEXT_LINE)
			.append("\tvisit date : ").append(visitDate).append(IConstant.SYS_NEXT_LINE).append(IConstant.SYS_NEXT_LINE);
		return buf.toString();
	}
}